<style>
    .radio-inline{
        padding-left: 0;
    }
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li><a href="#">文件管理</a></li>
        <li class="active">上传配置</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">
    <div class="box box-primary">
        <div class="box-body">
            <form class="form-horizontal" id="cloudConfigForm" method = 'post' th:action="@{/upload/saveConfig}">
                <div class="form-group">
                    <label class="col-sm-3 control-label">类型 :</label>
                    <div class="col-sm-8">
                        <label class="radio-inline pr-5"><input class="minimal" type="radio" th:field="*{cloudStorageConfig.type}" name="type" value="0"> 本地</label>
                        <label class="radio-inline pr-5"><input class="minimal" type="radio" th:field="*{cloudStorageConfig.type}" name="type" value="1"> 七牛云</label>
                        <label class="radio-inline pr-5"><input class="minimal" type="radio" th:field="*{cloudStorageConfig.type}" name="type" value="2"> 阿里云</label>
                        <label class="radio-inline pr-5"><input class="minimal" type="radio" th:field="*{cloudStorageConfig.type}" name="type" value="3"> 腾讯云</label>
                    </div>
                </div>
                <div id="local-form" th:class="${cloudStorageConfig.type==0?'':'display-none'}">
                    <div class="form-group">
                        <div class="col-sm-3 control-label">文件服务器域名:</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.localDomain}" name="localDomain" placeholder="本地文件服务器域名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">文件存储路径 :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.localPrefix}" name="localPrefix" require="必填项"  placeholder="本地文件路径前缀">
                        </div>
                    </div>
                </div>
                <div id="qiniu-form" th:class="${cloudStorageConfig.type==1?'':'display-none'}">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">域名 :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qiniuDomain}" name="qiniuDomain" require="必填项"  placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">前缀 :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qiniuPrefix}" name="qiniuPrefix" require="必填项"  placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">AccessKey :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qiniuAccessKey}" name="qiniuAccessKey" require="必填项"  placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">SecretKey :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qiniuSecretKey}" name="qiniuSecretKey" require="必填项"  placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">空间名 :</label>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qiniuBucketName}" name="qiniuBucketName" require="必填项"  placeholder="">
                        </div>
                    </div>
                </div>
                <div id="ali-form" th:class="${cloudStorageConfig.type==2?'':'display-none'}">
                    <div class="form-group">
                        <div class="col-sm-3 control-label">域名</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunDomain}" name="aliyunDomain" placeholder="阿里云绑定的域名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">路径前缀</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunPrefix}" name="aliyunPrefix" placeholder="不设置默认为空"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">EndPoint</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunEndPoint}" name="aliyunEndPoint" placeholder="阿里云EndPoint"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">AccessKeyId</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunAccessKeyId}" name="aliyunAccessKeyId" placeholder="阿里云AccessKeyId"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">AccessKeySecret</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunAccessKeySecret}" name="aliyunAccessKeySecret" placeholder="阿里云AccessKeySecret"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">BucketName</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.aliyunBucketName}" name="aliyunBucketName" placeholder="阿里云BucketName"/>
                        </div>
                    </div>
                </div>
                <div id="qcloud-form" th:class="${cloudStorageConfig.type==3?'':'display-none'}">
                    <div class="form-group">
                        <div class="col-sm-3 control-label">域名</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudDomain}" name="qcloudDomain" placeholder="腾讯云绑定的域名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">路径前缀</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudPrefix}" name="qcloudPrefix" placeholder="不设置默认为空"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">SecretId</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudSecretId}" name="qcloudSecretId" placeholder="腾讯云SecretId"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">SecretKey</div>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudSecretKey}" name="qcloudSecretKey" placeholder="腾讯云SecretKey"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">BucketName</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudBucketName}" name="qcloudBucketName" placeholder="腾讯云BucketName"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 control-label">Bucket所属地区</div>
                        <div class="col-sm-8 col-md-6">
                            <input type="text" class="form-control" th:value="${cloudStorageConfig.qcloudRegion}" name="qcloudRegion" placeholder="如：sh（可选值 ，华南：gz 华北：tj 华东：sh）"/>
                        </div>
                    </div>
                </div>
                <shiro:hasPermission name="upload:saveConfig">
                <div class="form-group">
                    <div class="col-sm-8  col-sm-offset-3">
                        <button id="saveConfig" type="button" class="btn btn-info">保存</button>
                    </div>
                </div>
                </shiro:hasPermission>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</section>
<script type="text/javascript">
    $(function () {
        $('[type="checkbox"].minimal,input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue',
        });

        $("#saveConfig").on('click', function () {
            Core.unmask("#saveConfig");
            Core.postAjax("/upload/saveConfig",$("#cloudConfigForm").serialize(),function (data) {
                Core.unmask("#saveConfig");
                layer.msg(data.msg);
            })
        });

        $("input[name=type]").on('ifChecked', function(event) {
            var ossType = $("input[name=type]:checked").val();
            if(ossType==0){
                $("#local-form").show();
                $("#qiniu-form").hide();
                $("#ali-form").hide();
                $("#qcloud-form").hide();
            }else if(ossType==1){
                $("#local-form").hide();
                $("#qiniu-form").show();
                $("#ali-form").hide();
                $("#qcloud-form").hide();
            }else if(ossType==2){
                $("#local-form").hide();
                $("#qiniu-form").hide();
                $("#ali-form").show();
                $("#qcloud-form").hide();
            }else if(ossType==3){
                $("#local-form").hide();
                $("#qiniu-form").hide();
                $("#ali-form").hide();
                $("#qcloud-form").show();
            }
        });
    });
</script>


